import React, { Component } from 'react'
import Son from '../components3/Son'

export default class Father extends Component {
    state = {
        str: "1"
    }
    sendStr = (str) => {
        this.setState({
            str
        })
    }
    render() {
        const { str } = this.state
        return (
            <div>
                Father -- { str }
                 {/* 1.在组件上自定义属性, * 值必须是一个函数 */}
                 {/* 2.在子组件中调用该函数, 传递实参(子组件中的内部状态) */}
                 {/* 3.在父组件中进行赋值 */}
                <Son sendStr={ this.sendStr }/>
            </div>
        )
    }
}
